package de.jamm.aws;

import de.hshannover.inform.muehle.strategy.Slot;

public class Konverter {

	
/*		slotCoord[0] = "a7";
		slotCoord[1] = "d7";
		slotCoord[2] = "g7";
		slotCoord[3] = "g4";
		slotCoord[4] = "g1";
		slotCoord[5] = "d1";
		slotCoord[6] = "a1";
		slotCoord[7] = "a4";

		// 2. Ebene
		slotCoord[8] = "b6";
		slotCoord[9] = "d6";
		slotCoord[10] = "f6";
		slotCoord[11] = "f4";
		slotCoord[12] = "f2";
		slotCoord[13] = "d2";
		slotCoord[14] = "b2";
		slotCoord[15] = "b4";

		// 3. Ebene
		slotCoord[16] = "c5";
		slotCoord[17] = "d5";
		slotCoord[18] = "e5";
		slotCoord[19] = "e4";
		slotCoord[20] = "e3";
		slotCoord[21] = "d3";
		slotCoord[22] = "c3";
		slotCoord[23] = "c4";
*/

	public static int konvertToInt(Slot slot){
		
//		for (int i = 0; i <= 23; i++){		
//			if ((String.valueOf(slot.getColumn()) + String.valueOf(slot.getRow())).equals(slotCoord[i]))
//				return i;
//		}
		String moves[] = {"a7","d7","g7","g4","g1","d1","a1","a4","b6","d6","f6","f4","f2","d2","b2","b4","c5","d5","e5","e4","e3","d3","c3","c4","0"};
		
		for (int i = 0; i<=24; i++){		
			if (moves[i].equalsIgnoreCase(slot.getColumn()+""+slot.getRow())){
				System.out.println("Konvertiere "+slot.getColumn()+slot.getRow()+" zu "+i);
				return i;
			}
		}
		throw new IllegalArgumentException("Konvertierung fehlgeschlagen!");
	}

	public static FieldSlot konvertToSlot(int slot) {
//		for (int i = 0; i <= 23; i++){
//			if (i == slot){
//				System.out.println(Integer.parseInt(slotCoord[i].substring(1)));
//				return new FieldSlot(slotCoord[i].charAt(0), Integer.parseInt(slotCoord[i].substring(1)), 0, false);
//			}
//		}
//		throw new IllegalArgumentException("Konvertierung fehlgeschlagen!");
		if(slot == 24){
			return null;
		}
		String moves[] = {"a7","d7","g7","g4","g1","d1","a1","a4","b6","d6","f6","f4","f2","d2","b2","b4","c5","d5","e5","e4","e3","d3","c3","c4"};
		String erg = moves[slot];
		FieldSlot ergebnis = new FieldSlot(erg.charAt(0),Integer.parseInt((erg.charAt(1))+""),0);
		System.out.println("Kovertiere von "+slot+" nach "+erg.toString());
		
		return ergebnis;
	}
}